package com.admin.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonView;
import com.vframework.common.response.R;
import com.vframework.config.annotation.admin.AdminRestController;
import com.vframework.system.user.entity.SysUser;
import com.vframework.system.user.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@AdminRestController
@RequestMapping("/demo")
@Api(tags = "样例，仅用于验证main中可以被base发现和管理")
public class DemoController {

    @Autowired
    SysUserService userService;

    @GetMapping
    @PreAuthorize("hasAuthority('sys:user:list')")
    @JsonView(SysUser.UserSimpleView.class)
    @ApiOperation(value = "用户列表")
    public R<List<SysUser>> list() {
        return R.success(userService.list(new QueryWrapper<>()));
    }
}
